﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BatchStore.aspx.cs" Inherits="H2.NET.Web.Pages.SMD.BatchStore" %>

<%@ Register Src="../../Controls/DwzAssessment.ascx" TagName="DwzAssessment" TagPrefix="uc" %>
<%@ Register Src="../../Controls/DwzAssessmentList.ascx" TagName="DwzAssessmentList" TagPrefix="uc" %>
<%@ Register src="../../Controls/AjaxUpload.ascx" tagname="ajaxUpload" tagprefix="uc" %>
<%@ Register Src="uc_change_field.ascx" TagName="uc_change_field" TagPrefix="uc" %>
<%@ Register src="uc_head.ascx" tagname="uc_head" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
<head id="Head1" runat="server">
    <title>批量变更门店数据</title>
    <link href="<%=Page.ResolveUrl("~/Resource/Css/Style.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/jBox/Blue/jbox.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/LigerUI/skins/Aqua/css/ligerui-all.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/LigerUI/skins/Gray2014/css/all.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/LigerUI/LigeruiExtend.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.css")%>" rel="stylesheet" type="text/css" />
    <script src="<%=Page.ResolveUrl("~/Resource/dwz/js/jquery-1.7.2.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/Js/Common.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-2.3.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/jBox/jquery.jBox-zh-CN.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/LigerUI/js/ligerui.all.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/qtip/jquery.qtip.min.js")%>" type="text/javascript"></script>
    <script src="<%=Page.ResolveUrl("~/Resource/My97DatePicker/WdatePicker.js")%>" type="text/javascript"></script>
    <!--[if lt IE 8 ]><script src="<%=Page.ResolveUrl("~/Resource/Js/json2.min.js")%>" type="text/javascript"></script><![endif]-->
    <style type="text/css">
        #dialog-form { font-size: 62.5%; }
        #dialog-form label { width: 150px; display: inline-block; font-weight: 700; text-align: right; }
        #dialog-form input.text { margin-bottom: 12px; width: 180px; padding: .4em; }
        #dialog-form fieldset { padding: 0; border: 0; margin-top: 15px; }
        #dialog-form fieldset ul li { display: inline-block; width: 400px; float: left; height: 40px; line-height: 40px; }
        .formTable input { padding: 2px; }
        .l-grid-row-cell-inner .updated { display: inline-block; color: #ff0000; width: 100%; }
        .required { color: red; }
        .seachStore { display: inline-block; margin-top: 10px; height: 25px; line-height: 25px; }

    </style>
    <script type="text/javascript">
        var update_logs = <%=update_logs%>;
        var storegrid;
        var isDblClickRow = true;
        $(function () {
  
            storegrid = $("#storegrid").ligerGrid({
                columns: [{
                        display: '操作', id: 'remove', isSort: false, width: 50, frozen: true, render: function (rowdata, rowindex, value) {
                            return "<a href='javascript:deleteRow(" + rowindex + ","+rowdata.StoreID+")'>移除</a> ";
                        }
                    },{
                        display: '授权号', name: 'AuthID', width: 100, frozen: true,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'AuthID');
                        }
                    }, {
                        display: '门店名称', name: 'StoreName', width: 160, align: 'left', frozen: true,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'StoreName');
                        }
                    }, {
                        display: '门店状态', name: 'StoreStatus', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'StoreStatus');
                        }
                    }, {
                        display: '门店类型', name: 'StoreType', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'StoreType');
                        }
                    },{
                        display: '渠道', name: 'Channel', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'Channel');
                        }
                    },{
                        display: '最初开业时间', name: 'FirstStartDate', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'FirstStartDate');
                        }
                    },{
                        display: '目前开业时间', name: 'CurrentStartDate', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'CurrentStartDate');
                        }
                    },{
                        display: '区域', name: 'Region', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'Region');
                        }
                    },{
                        display: '省份', name: 'Province', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'Province');
                        }
                    }, {
                        display: '城市', name: 'CityName', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'CityName');
                        }
                    }, {
                        display: '城市类型', name: 'CityClass', width: 100, 
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'CityClass');
                        }
                    },{
                        display: '门店地址', name: 'StoreAddress', width: 200, align: 'left',
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'StoreAddress');
                        }
                    }, {
                        display: '门店联络人', name: 'ContactPerson', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'ContactPerson');
                        }
                    }, {
                        display: '联络电话', name: 'PhoneNumber', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'PhoneNumber');
                        }
                    }, {
                        display: '门店建筑面积', name: 'StoreSize', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'StoreSize');
                        }
                    }, {
                        display: '调色服务', name: 'IsTintingService', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'IsTintingService');
                        }
                    }, {
                        display: '色彩咨询', name: 'IsColourService', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'IsColourService');
                        }
                    }, {
                        display: '官网屏蔽', name: 'ShowInWebsite', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'ShowInWebsite');
                        }
                    }, {
                        display: 'SMS账号', name: 'AccountCMS', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'AccountCMS');
                        }
                    }, {
                        display: '经度', name: 'Lon', width: 100,
                        render: function (rowdata, rowindex, value) {
                            return InitCell(rowdata, rowindex, value, 'Lon');
                        }
                    }, 
                    {
                        display: '纬度', name: 'Lat', width: 100,
                        render: 
                            function (rowdata, rowindex, value) 
                            {
                                return InitCell(rowdata, rowindex, value, 'Lat');
                            }
                    }
                ],
                width: '100%', height: '70%', usePager: false,
                // 设置数据源
                dataAction: 'server', rownumbers: true, data: { Rows: <%=stores_json%> },
                onAfterShowData: function(currentData) {
                    setTimeout(function() {
                        $("span[tooltip='true']").qtip({
                            position: {
                                target: 'mouse',
                                adjust: { x: 10, y: 10 }
                            }
                        });
                    }, 500);
                },
                onDblClickRow: function (data, rowindex, rowobj) {
                    if(isDblClickRow) {
                        openStoreDialog();
                        $.jBox.getBox().find(":hidden[name='StoreID']").val(data.StoreID);
                        $.jBox.getBox().find(":text[name='AuthID']").val(data.AuthID);
                        $.jBox.getBox().find("#StoreName").val(data.StoreName);
                        $.jBox.getBox().find("#ContactPerson").val(data.ContactPerson);
                        $.jBox.getBox().find(".jbox-container #StoreStatus").val(data.StoreStatus);
                        if (data.StoreType == "DDCN" || data.StoreType == "DCSS") {
                            $.jBox.getBox().find(".jbox-container #StoreStatus").hide();
                            $.jBox.getBox().find(".jbox-container #l_StoreStatus").text(data.StoreStatus);
                        }
                        $.jBox.getBox().find("#StoreAddress").val(data.StoreAddress);
                        $.jBox.getBox().find("#Lon").val(data.Lon);
                        $.jBox.getBox().find("#Lat").val(data.Lat);
                        $.jBox.getBox().find(".jbox-container #StoreType").val(data.StoreType);
                        $.jBox.getBox().find(".jbox-container #l_StoreType").text(data.StoreType);
                        $.jBox.getBox().find(".jbox-container #Channel").val(data.Channel);
                        $.jBox.getBox().find(".jbox-container #FirstStartDate").val(data.FirstStartDate);
                        $.jBox.getBox().find(".jbox-container #CurrentStartDate").val(data.CurrentStartDate);
                        //门店区域
                        $.jBox.getBox().find(".jbox-container #Region").val(data.Region);

                        //调色服务
                        if(data.IsTintingService && data.IsTintingService == true || data.IsTintingService == "True") {
                            $.jBox.getBox().find("[name='cb_IsTintingService']").attr("Checked","Checked");
                            $.jBox.getBox().find(":hidden[name='IsTintingService']").val("True");
                        } else {
                            $.jBox.getBox().find(":hidden[name='IsTintingService']").val("False");
                        }
                        
                        //色彩咨询
                        if(data.IsColourService && data.IsColourService == true || data.IsColourService == "True") {
                            $.jBox.getBox().find("[name='cb_IsColourService']").attr("Checked","Checked");
                            $.jBox.getBox().find(":hidden[name='IsColourService']").val("True");
                        } else {
                            $.jBox.getBox().find(":hidden[name='IsColourService']").val("False");
                        }
                        //官网屏蔽
                        if(data.ShowInWebsite && data.ShowInWebsite == true || data.ShowInWebsite == "True") {
                            $.jBox.getBox().find("[name='cb_ShowInWebsite']").attr("Checked","Checked");
                            $.jBox.getBox().find(":hidden[name='ShowInWebsite']").val("True");
                        } else {
                            $.jBox.getBox().find(":hidden[name='ShowInWebsite']").val("False");
                        }
                        $.jBox.getBox().find("#PhoneNumber").val(data.PhoneNumber);
                        $.jBox.getBox().find("#StoreSize").val(data.StoreSize);
                        $.jBox.getBox().find("#CloseDate").val(data.CloseDate);
                        $.jBox.getBox().find("#CloseReason").val(data.CloseReason);
                        $.jBox.getBox().find(".jbox-container #CloseType").val(data.CloseType);
                        $.jBox.getBox().find("#l_NewFitment").val(data.NewFitment);
                        $.jBox.getBox().find("[name='NewFitment']").val(data.NewFitment);
                        $.jBox.getBox().find("#AccountCMS").val(data.AccountCMS);
                        $.jBox.getBox().find("#dealer_DealerCode").val();
                        $.jBox.getBox().find("#dealer_Name").val(data);
                        $.jBox.getBox().find("#StoreApprovedDate").val(data.StoreApprovedDate);
                        $.jBox.getBox().find("#EapproveSN").val(data.EapproveSN);

                        if(data.IsRenew != null && data.IsRenew == true || data.IsRenew == "True"){
                            $.jBox.getBox().find("[name='cb_IsRenew']").attr("checked","checked");
                        }
                        if(data.IsUpgraded != null && data.IsUpgraded == true || data.IsUpgraded == "True"){
                            $.jBox.getBox().find("[name='cb_IsUpgraded']").attr("checked","checked");
                        }
                        if(data.IsDowngraded != null && data.IsDowngraded == true || data.IsDowngraded == "True"){
                            $.jBox.getBox().find("[name='cb_IsDowngraded']").attr("checked","checked");
                        }

                        $.jBox.getBox().find("[name='OpenBusinessDate']").val(data.OpenBusinessDate);
                        $.jBox.getBox().find("[name='BeforeUpgradedType']").val(data.BeforeUpgradedType);
                        $.jBox.getBox().find("[name='BeforeDowngradedType']").val(data.BeforeDowngradedType);
                        $.jBox.getBox().find("[name='BeforeRenewType']").val(data.BeforeRenewType);
                        $.jBox.getBox().find("[name='LastRenewDate']").val(data.LastRenewDate);
                        $.jBox.getBox().find("[name='CurrentStartDate']").val(data.CurrentStartDate);

                        loadRadio();

                        initProvince($.jBox.getBox().find("#Region"),
                            // 初始化省份、城市
                            function () {
                                $.jBox.getBox().find(".jbox-container #Province").val(data.Province);
                                initProvince($.jBox.getBox().find("#Province"),
                                    function () {
                                        $.jBox.getBox().find(".jbox-container #CityName").val(data.CityName);
                                    });
                            });

                        // todo:表单默认选中已修改的值

                        var names = new Array("StoreID","AuthID","StoreName","StoreAddress","Lon","Lat","ContactPerson","PhoneNumber","StoreStatus","Region","Province","CityName");
                        for (var l in update_logs) {
                            if (update_logs[l].DataID == data.StoreID) {
                                for(var i in names) {
                                    var name = names[i];
                                    if(name == update_logs[l].FieldName) {
                                        $("#dialog-form [name='" + name + "']").val(update_logs[l].AfterValue);
                                    }
                                }
                            }
                        }

                    }
                }                
            });

            /* 初始化单元格 st */
            function InitCell(rowdata, rowindex, value, name) {
                var h = value;
                for (var l in update_logs) {
                    if (update_logs[l].DataID == rowdata.StoreID && update_logs[l].FieldName == name) {
                        var id = rowdata.__id + rowdata.__index;

                        var title = "<b>修改前：</b><br />" + update_logs[l].BeforeValue;
                        title += "<br /><b>修改后:</b><br />" + update_logs[l].AfterValue;

                        h = "<span id='" + id + "' tooltip='true' class='updated' title='" + title + "'>" + 
                            update_logs[l].AfterValue + "</span>";
                    }
                }
                return h;
            }

            /* 初始化tip ed */


            var step = "<%=TaskAPI.Step%>";
            var readonly = "<%=H2.NET.Common.AksRequest.GetString("readonly")%>";
            if(step == "DMO Commit" || readonly == "1") {
                isDblClickRow = false;
                storegrid.toggleCol('remove', false);
            }
        });

        

        /* 提交表单 st */
        function confirmSubmit() {
            if (window.confirm("确认要提交吗？")) {
                $.jBox.tip('正在处理，请稍等...', 'loading');
                return true;
            }
            return false;
        }
        /* 提交表单 ed */

        /* 地区级联 st */
        function initProvince(arg, callback) {
            $.jBox.closeTip();
            var val = $(arg).val();
            var id = $(arg).attr("id");
            if ($.trim(val)) {
                $.ajax({
                    type: 'POST',
                    url: '<%=Page.ResolveUrl("~/pages/smd/store.aspx?action=initProvince")%>',
                    data: { ar: val, type: (id == "Province" ? "province" : "city") },
                    dataType: "json",
                    cache: false,
                    success: function (json) {
                        var rst = json.navTabId.split("|");
                        var html = "";
                        for (var i = 0; i < rst.length; i++) {
                            if (rst[i]) {
                                var list = rst[i].split(",");
                                html += "<option value='" + list[0] + "'>" + list[1] + "</option>";
                            }
                        }
                        if (id == "Province") {
                            $.jBox.getBox().find("#CityName").find("option:gt(0)").remove().end().append(html);

                        }
                        else {
                            $.jBox.getBox().find("#Province").find("option:gt(0)").remove().end().append(html);
                            $.jBox.getBox().find("#CityName").find("option:gt(0)").remove();
                        }

                        if (jQuery.isFunction(callback)) {
                            callback();
                        }
                    }
                });
            }
            else {
                if (id == "Province") {
                    $.jBox.getBox().find("#CityName").find("option:gt(0)").remove();

                }
                else {
                    $.jBox.getBox().find("#Province").find("option:gt(0)").remove();
                    $.jBox.getBox().find("#CityName").find("option:gt(0)").remove();
                }
            }
        }
        /* 地区级联 ed */

        /* 删除行 st */
        function deleteRow(rowid,storeID) {
            if (confirm('确定移除?')) {
                $.ajax({
                    type: 'POST',
                    url: '<%= Page.ResolveUrl("~/Pages/SMD/ajaxtools/handler.ashx?action=delete_changed_store")%>',
                    data: { id: storeID },
                    success: function (result) {
                        storegrid.deleteRow(rowid);
                    },
                    error: function (result) {
                        $.jBox.tip(result, 'error');
                    }
                });
            }
        }
        /* 删除行 ed */

        /* 选择变更的数据 st */
        var test = [];
        function selectData() {
            var storeIds = [];
            var storejson = storegrid.getData();
            for(var o in storejson) {
                storeIds.push(storejson[o].StoreID);
            }

            var fn = $.ligerui.getPopupFn({
                condition:{
                    title: ['选择门店'],
                    fields: [{ name: 'keyword',labelWidth:160, label: '授权号/门店名称/门店地址',type:"text",op:'like', title:'请输入关键字'}] 
                },
                top : 80,
                onSelect: function (e) {
                    storegrid.addRows(e.data);
                },
                grid: {columns: [{
                            display: '授权号', name: 'AuthID', width: 100
                        }, {
                            display: '门店名称', name: 'StoreName', width: 160, align: 'left'
                        }, {
                            display: '门店状态', name: 'StoreStatus', width: 100
                        }, {
                            display: '门店类型', name: 'StoreType', width: 100
                        }, {
                            display: '区域', name: 'Region', width: 100
                        }, {
                            display: '省份', name: 'Province', width: 100
                        }, {
                            display: '城市', name: 'CityName', width: 100
                        }, {
                            display: '门店地址', name: 'StoreAddress', width: 200, align: 'left'
                        }, {
                            display: '门店联络人', name: 'ContactPerson', width: 100
                        }, {
                            display: '联络电话', name: 'PhoneNumber', width: 100
                        }],
                    width: '100%', height: '70%',checkbox:true,onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow,
                    // 设置数据源
                    dataAction: 'server', url: "AjaxTools/Handler.ashx?action=get_smd_store&taskid=<%=TaskAPI.TaskID%>&storeIds="+storeIds.join(","), rownumbers: true
                }
            });

            fn();
        }
        function f_onCheckAllRow(checked)
        {
            for (var rowid in this.records)
            {
                if(checked)
                    addCheckedCustomer(this.records[rowid]);
                else
                    removeCheckedCustomer(this.records[rowid]);
            }
        }
 
        /*
        该例子实现 表单分页多选
        即利用onCheckRow将选中的行记忆下来，并利用isChecked将记忆下来的行初始化选中
        */
        var checkedCustomer = [];
        function findCheckedCustomer(row)
        {
            for(var i =0;i<checkedCustomer.length;i++)
            {
                if(checkedCustomer[i] == row) return i;
            }
            return -1;
        }
        function addCheckedCustomer(row)
        {
            if(findCheckedCustomer(row) == -1)
                checkedCustomer.push(row);
        }
        function removeCheckedCustomer(row)
        {
            var i = findCheckedCustomer(row);
            if(i==-1) return;
            checkedCustomer.splice(i,1);
        }
      
        function f_onCheckRow(checked, data)
        {
            if (checked) addCheckedCustomer(data);
            else removeCheckedCustomer(data);
        }
       

        /* 打开选择门店窗体 st */
        function openStoreDialog() {
        
            $.jBox("id:editStore", {
                title: "修改门店信息",
                width: 950,
                height: 480,
                buttons: {'确认修改': 1, '取消修改': 0},
                submit: function (v, h, f) {
                    if (v == 0) {
                        return true; // close the window
                    }
                    else {
                        // 更新grid数据
                        var $form = $('<form id="f1"></form>');
                        $form.append($.jBox.getBox().find(".jbox-container .formTable").clone());
                        var required = true;
                        $.jBox.getBox().find("#editStore").find("[datatype='*']").each(function(){
                            if(!$(this).val()){
                                required = false;
                            }
                        });
                        if(!required){
                            $.jBox.tip("请填写完整后提交", 'error');
                            return false;
                        }
                     
                        storegrid.updateRow(storegrid.getSelected(), $form.serializeJson());

                        // 提交并保存变更的数据
                        $.ajax({
                            type: 'POST',
                            url: '<%= Page.ResolveUrl("~/Pages/SMD/ajaxtools/handler.ashx?action=save_changed_store")%>',
                            data: { data: JSON.stringify(storegrid.getSelected()) },
                            dataType: "json",
                            success: function (json) {
                                update_logs = json;
                                storegrid.reload();
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                //console.log(XMLHttpRequest.status);
                                //console.log(XMLHttpRequest.readyState);
                                //console.log(textStatus);
                            }
                        });
                    }
                    return true;
                }
            });
        }
        /* 打开选择门店窗体 ed */
        
        var MphSearch = function storeSearch(pageclickednumber) {
            $.ajax({
                type: 'POST',
                url: '<%= Page.ResolveUrl("~/Pages/SMD/ajaxtools/handler.ashx")%>',
                data: { action: 'search_store',
                    dealName: $.jBox.getBox().find(":text[name='dealName']").val(),
                    dealName: $.jBox.getBox().find(":text[name='storeAuthID']").val(),
                    dealName: $.jBox.getBox().find(":text[name='storeName']").val(),
                    dealName: $.jBox.getBox().find(":text[name='cityClass']").val(),
                    taskid: '<%=TaskAPI.TaskID%>',
                    pageNumber:pageclickednumber,
                    pageSize:14},
                beforeSend: function () {
                    $.jBox.getBox().find("#btn_store_search").val("加载中...");
                },
                complete: function () {
                    $.jBox.getBox().find("#btn_store_search").val("检索");
                },
                success: function (result) {
                    
                    $("#jbox-content #pager").pager({ pagenumber: pageclickednumber, pagecount: result.pageNum, buttonClickCallback:storeSearch });
                    var data = result.data;
                    var html = "";
                    for(var o in data){
                        html += "<tr>";
                        html += " <td> <checkbox name='ck_storeID'/> storeID='"+data[o].StoreID+"'>";
                        html += " <td align=center>" + data[o].AuthID + "</td>";
                        html += " <td align=center>" + data[o].StoreName + "</td>";
                        html += " <td align=center>" + data[o].StoreType + "</td>";
                        html += " <td align=center>" + data[o].CityClass + "</td>";
                        html += " <td align=center>" + data[o].Region + "</td>";
                        html += " <td align=center>" + data[o].Province + "</td>";
                        html += " <td align=center>" + data[o].CityName + "</td>";
                        html += " <td align=center>" + data[o].StoreAddress + "</td>";
                        html += "</tr>";
                    }

                    $.jBox.getBox().find("#dialog_store_tbody").html(html);

                    $.jBox.getBox().find("#dialog_store_tbody tr").dblclick(function () {
                        $("#meiPinNo").val($(this).attr("mph"));
                        $.jBox.close();
                    });
                }
            });
        }
       
    </script>
</head>
<body>
    <div class="flowpage">
        <form id="form1" runat="server">
        <!-- 标题 st -->
        <uc1:uc_head ID="uc_head1" runat="server" />
        <!-- 标题 ed -->
        <!-- 表单内容 st -->

        <div><a href="javascript:;" onclick="selectData()" id="lb_selectData" runat="server" class="seachStore u-btn">选取门店</a></div>
        <div style="margin: 10px 0;">
            <div id="storegrid" style="margin-bottom: 5px;">
            </div>
            <table class="formTable">
                <!-- 审批列表 st -->
                <tbody id="assessment" runat="server" visible="false">
                    <tr>
                        <td class="title" colspan="6">
                            审批列表
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6">
                            <uc:DwzAssessmentList ID="DwzAssessmentList1" runat="server" />
                        </td>
                    </tr>
                </tbody>
                <tbody>
                    <tr>
                        <th class="title" colspan="6"><span style=" color:Red">如果勾选了官网屏蔽，请上传相应的DR2审批邮件</span></th>
                    </tr>
                    <tr>
                        <th>相关附件：</th>
                        <td colspan="5">
                            <uc:ajaxUpload ID="ajaxUpload1" runat="server" />
                        </td>
                    </tr>
                </tbody>
                <!-- 审批列表 ed -->
                <!-- 字段变更列表 st -->
                <tbody id="changelogs" runat="server" visible="false">
                    <tr>
                        <th>
                            字段变更列表：
                        </th>
                        <td colspan="5">
                            <uc:uc_change_field ID="uc_change_field1" runat="server" />
                        </td>
                    </tr>
                </tbody>
                <!-- 字段变更列表 ed -->
                <!-- 审批意见 st -->
                <tbody>
                    <uc:DwzAssessment ID="DwzAssessment1" runat="server" />
                </tbody>
                <!-- 审批意见 ed -->
            </table>
            <%  if(H2.NET.Common.AksRequest.GetString("showbtn") != "0")
                { %>
                <div style="margin: 5px; padding-bottom: 10px; text-align: center;">
                    <asp:Button ID="btn_submit" runat="server" CssClass="u-btn" Text="提交(Submit)" OnClick="btn_submit_Click" OnClientClick="return confirmSubmit();" />
                    <input type="button" class="u-btn u-btn-c4" value="关闭(Close)" onclick="custom_close()" />
                    <asp:HyperLink ID="hl_ExportPdf" runat="server" Visible="false" Target="_blank" CssClass="u-btn u-btn-c3" style="height:28px; line-height:28px; display:inline-block;">生成(PDF)</asp:HyperLink>
                    <asp:Button ID="btn_print" runat="server" CssClass="u-btn u-btn-c2" Text="打印(Print)" OnClientClick="window.print()" Visible="false" />
                </div>
            <%  } %>
        </div>
        <!-- 表单内容 ed -->

        <!-- 修改页面 st -->
        <!-- 门店信息 st -->
        <div id="editStore" style="display: none">
        <script type="text/javascript">
            //初始化单选框触发条件
            function loadRadio() {
                $.jBox.getBox().find("[name=cb_IsUpgraded]").click(function () {
                    IsUpgradedFunction(this);
                });

                $.jBox.getBox().find("[name=cb_IsDowngraded]").click(function () {
                    IsDowngradedFunction(this);
                });

                $.jBox.getBox().find("[name=cb_IsRenew]").click(function () {
                    isRenewFunction(this);
                });

                $.jBox.getBox().find("[name=cb_IsUpgraded]").each(function () {
                    IsUpgradedFunction(this);
                });

                $.jBox.getBox().find("[name=cb_IsDowngraded]").each(function () {
                    IsDowngradedFunction(this);
                });

                $.jBox.getBox().find("[name=cb_IsRenew]").each(function () {
                    isRenewFunction(this);
                });
            };

            function IsUpgradedFunction(obj) {
                if ($(obj).attr("checked") == "checked") {
                    $.jBox.getBox().find("#BeforeUpgradedType").show();
                    $.jBox.getBox().find(":hidden[name='IsUpgraded']").val("True");
                    $.jBox.getBox().find("#BeforeUpgradedType").attr("datatype", "*").after("<em class='required'>*</em>");
                } else {
                    $.jBox.getBox().find("#BeforeUpgradedType").hide();
                    $.jBox.getBox().find(":hidden[name='IsUpgraded']").val("False");
                    $.jBox.getBox().find("#BeforeUpgradedType").attr("datatype", "").parent().find("em").remove();
                }
            }

            function IsDowngradedFunction(obj) {
                if ($(obj).attr("checked") == "checked") {
                    $.jBox.getBox().find("#BeforeDowngradedType").show();
                    $.jBox.getBox().find(":hidden[name='IsDowngraded']").val("True");
                    $.jBox.getBox().find("#BeforeDowngradedType").attr("datatype", "*").after("<em class='required'>*</em>");
                } else {
                    $.jBox.getBox().find("#BeforeDowngradedType").hide();
                    $.jBox.getBox().find(":hidden[name='IsDowngraded']").val("False");
                    $.jBox.getBox().find("#BeforeDowngradedType").attr("datatype", "").parent().find("em").remove();
                }
            }

            function isRenewFunction(obj) {
                if ($(obj).attr("checked") == "checked") {
                    $.jBox.getBox().find(":hidden[name='IsRenew']").val("True");
                    $.jBox.getBox().find("#BeforeRenewType").show();
                    $.jBox.getBox().find("#BeforeRenewType").attr("datatype", "*").after("<em class='required'>*</em>");
                    $.jBox.getBox().find("#LastRenewDate").show();
                    $.jBox.getBox().find("#LastRenewDate").attr("datatype", "*").after("<em class='required'>*</em>");
                } else {
                    $.jBox.getBox().find(":hidden[name='IsRenew']").val("False");
                    $.jBox.getBox().find("#BeforeRenewType").hide();
                    $.jBox.getBox().find("#BeforeRenewType").attr("datatype", "").parent().find("em").remove();
                    $.jBox.getBox().find("#LastRenewDate").hide();
                    $.jBox.getBox().find("#LastRenewDate").attr("datatype", "").parent().find("em").remove();
                }
            }

            function ChangeStoreStatus(obj) {
                if ($(obj).val() == "营业" || $(obj).val() == "") {
                    $(obj).parent().attr("colspan", "1");
                    $(".yy").each(function () {
                        $(this).show();
                    });
                } else {
                    $(obj).parent().attr("colspan", "3");
                    $(".yy").each(function () {
                        $(this).hide();
                    });
                }
            }

            function doCheckTintingService(obj) {
                var check = $.jBox.getBox().find("#cb_IsTintingService").attr("checked");
                if (check == "checked") {
                    $.jBox.getBox().find("#IsTintingService").val("True");
                } else {
                    $.jBox.getBox().find("#IsTintingService").val("False");
                }
            }

            function doCheckColourService(obj) {
                var check = $.jBox.getBox().find("#cb_IsColourService").attr("checked");
                if (check == "checked") {
                    $.jBox.getBox().find("#IsColourService").val("True");
                } else {
                    $.jBox.getBox().find("#IsColourService").val("False");
                }
            }

            function doCheckShowInWebsite(obj) {
                var check = $.jBox.getBox().find("#cb_ShowInWebsite").attr("checked");
                if (check == "checked") {
                    $.jBox.getBox().find("#ShowInWebsite").val("True");
                } else {
                    $.jBox.getBox().find("#ShowInWebsite").val("False");
                }
            }
        </script>

            <table class="formTable" style="height: auto;margin:5px;width:99%">
                <!-- 门店信息 st -->
                <tbody id="tbody_store" runat="server">
                    <tr>
                        <td class="title" colspan="6" onclick="createStoreName()">门店信息（通用）</td>
                    </tr>
                    <tr>
                        <th>
                            门店授权号：
                        </th>
                        <td>
                            <asp:TextBox ID="AuthID" runat="server" ReadOnly="true"></asp:TextBox>
                        </td>
                        <th>门店状态：</th>
                        <td>
                            <label id="l_StoreStatus"></label>
                            <asp:DropDownList ID="StoreStatus" runat="server" datatype="*" nullmsg="请选择门店状态" onChange="ChangeStoreStatus(this)"></asp:DropDownList>
                        </td>
                        <th class="yy">启动营业时间：</th>
                        <td class="yy">
                            <asp:TextBox ID="OpenBusinessDate" runat="server" CssClass="Wdate" onfocus="WdatePicker()"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>门店类型：</th>
                        <td>
                            <label id="l_StoreType"></label>
                            <asp:DropDownList ID="StoreType" runat="server" datatype="*" nullmsg="请选择门店类型" style="display:none"></asp:DropDownList>
                        </td>
                        <th>渠道：</th>
                        <td>
                            <asp:DropDownList ID="Channel" runat="server" datatype="*" nullmsg="请选择渠道"></asp:DropDownList>
                        </td>
                        <th>门店装修类型：</th>
                        <td>
                            <asp:Label ID="l_NewFitment" runat="server"></asp:Label>
                            <asp:HiddenField ID="NewFitment" runat="server"/>
                        </td>
                    </tr>
                    <tr>
                        <th>门店区域：</th>
                        <td>
                            <asp:TextBox ID="Region" runat="server" ReadOnly="true"></asp:TextBox>
                        </td>
                        <th>门店省份：</th>
                        <td>
                            <asp:TextBox ID="Province" runat="server" ReadOnly="true"></asp:TextBox>
                        </td>
                        <th>门店城市：</th>
                        <td>
                            <asp:DropDownList ID="CityName" runat="server" datatype="*" nullmsg="请选择门店城市">
                                <asp:ListItem Text="==请选择==" Value=""></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>门店名称：</th>
                        <td colspan="5">
                            <asp:TextBox ID="StoreName" runat="server" Width="500"></asp:TextBox>
                            <asp:HiddenField ID="hd_store_id" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <th>联系人：</th>
                        <td>
                            <asp:TextBox ID="ContactPerson" runat="server" datatype="*" nullmsg="请填写联系人"></asp:TextBox>
                        </td>
                        <th>电话：</th>
                        <td colspan="3">
                            <asp:TextBox ID="PhoneNumber" runat="server" datatype="*" nullmsg="请填写联系电话"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>门店地址：</th>
                        <td colspan="5">
                            <asp:TextBox ID="StoreAddress" runat="server" Width="500" datatype="*" nullmsg="请填写门店地址"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>经度：</th>
                        <td>
                            <asp:TextBox ID="Lon" runat="server" datatype="*" nullmsg="请填写经度"></asp:TextBox>
                        </td>
                        <th>纬度：</th>
                        <td colspan="3">
                            <asp:TextBox ID="Lat" runat="server" datatype="*" nullmsg="请填写纬度"></asp:TextBox>
                            <span style="color:red;">请输入6位小数的经纬度，如：13.123456</span>
                        </td>
                    </tr>
                </tbody>
                <!-- 门店信息 ed -->
        
                <tbody>
                    <tr>
                        <td class="title" colspan="6">门店信息（DDCN&DCSS必填）</td>
                    </tr>
                    <tr>
                        <th>门店建筑面积：</th>
                        <td>
                            <asp:TextBox ID="StoreSize" runat="server"></asp:TextBox>M<sup>2</sup>
                        </td>
                        <th>最初开业时间：</th>
                        <td>
                            <asp:TextBox ID="FirstStartDate" runat="server" CssClass="Wdate" onfocus="WdatePicker()"></asp:TextBox>
                        </td>
                        <th>
                            目前门店开业时间：
                        </th>
                        <td>
                            <asp:TextBox ID="CurrentStartDate" runat="server" CssClass="Wdate" Enabled="false" onfocus="WdatePicker() "></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>色彩咨询：</th>
                        <td>
                            <asp:CheckBox ID="cb_IsColourService" onclick="doCheckColourService(this)" runat="server" />
                            <asp:HiddenField ID="IsColourService" runat="server" />
                        </td>
                        <th>调色服务：</th>
                        <td>
                            <asp:CheckBox ID="cb_IsTintingService" onclick="doCheckTintingService(this)" runat="server" />
                            <asp:HiddenField ID="IsTintingService" runat="server" />
                        </td>
                        <th>官网屏蔽：</th>
                        <td>
                            <asp:CheckBox ID="cb_ShowInWebsite" onclick="doCheckShowInWebsite(this)" runat="server" Text=" 必须提交DR2审批邮件"  />
                            <asp:HiddenField ID="ShowInWebsite" runat="server" />
                        </td>
                    </tr>
                </tbody>
                
                <tbody>
                    <tr>
                        <td class="title" colspan="6">历史情况</td>
                    </tr>
                    <tr id="tr_storeUpgrad" runat="server">
                        <th>是否为升级：</th>
                        <td>
                            <asp:CheckBox ID="cb_IsUpgraded" Enabled="false" runat="server" />
                            <asp:HiddenField ID="IsUpgraded" runat="server"/>
                        </td>
                        <th>升级前门店类型：</th>
                        <td colspan="3">
                            <asp:DropDownList ID="BeforeUpgradedType" Enabled="false" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr id="tr_storeDowngrad" runat="server">
                        <th>是否为降级：</th>
                        <td>
                            <asp:CheckBox ID="cb_IsDowngraded" Enabled="false" runat="server" />
                            <asp:HiddenField ID="IsDowngraded"  runat="server" />
                        </td>

                        <th>降级前门店类型：</th>
                        <td colspan="3">
                            <asp:DropDownList ID="BeforeDowngradedType" Enabled="false" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr id="tr_storeRenew" runat="server">
                        <th>是否有翻新：</th>
                        <td>
                            <asp:CheckBox ID="cb_IsRenew" Enabled="false" runat="server" />
                            <asp:HiddenField ID="IsRenew"  runat="server" />
                        </td>
                        <th>翻新前门店类型：</th>
                        <td>
                            <asp:DropDownList ID="BeforeRenewType" Enabled="false" runat="server">
                            </asp:DropDownList>
                        </td>
                        <th>最新翻新日期：</th>
                        <td>
                            <span>
                                <asp:TextBox ID="LastRenewDate" runat="server" Enabled="false" CssClass="Wdate" datatype="" onfocus="WdatePicker()"></asp:TextBox>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <th>系统审批日期：</th>
                        <td>
                            <asp:TextBox ID="StoreApprovedDate" runat="server" Enabled="false" CssClass="Wdate" onfocus="WdatePicker()"></asp:TextBox>
                        </td>
                        <th>系统流水号：</th>
                        <td colspan="3">
                            <asp:TextBox ID="EapproveSN" Enabled="false" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </tbody>
                </table>
        </div>
        <!-- 门店信息 ed -->
        <!-- 修改页面 ed -->
        </form>
    </div>
</body>
</html>
